<?
session_start();
if (!isset($_SESSION["sess_Username"])) { 
?>
  <script>
	alert('กรุณาทำการ Login เข้าระบบก่อน');
	</script>    
	<meta http-equiv='refresh' content='0;URL=admin_login.php'>
<? 
} 
include ("connectdb.php");
?>
<script>
getdetail();
</script>

<script>
function getdetail(){
<?php 
	
	include						"connectdb.php";
	$tb =							"ag_vdodetail"; 
	mysql_select_db($dbname) or die("เลือกฐานข้อมูลไม่ได้"); /* ทําการเลือกฐานขอมูลกอน */ 
	$sql =						"Select * From $tb where vdo_id=$id"; 
	$db_query =				mysql_db_query($dbname,$sql); 
	$num_rows =			mysql_num_rows($db_query); /* นับ Reccord ทีพบ */
	$result =					mysql_fetch_array($db_query); 
	$vdo_id=					$result[vdo_id]; 
	$vdo_series_name	=	$result[vdo_series_name];
	$vdo_name=				$result[vdo_name]; 
	$vdo_view=				$result[vdo_view]; 
	$vdo_desc=				$result[vdo_desc]; 
	$vdo_author=			$result[vdo_author];
	$vdo_year=				$result[vdo_year];
	$vdo_cover=				$result[vdo_cover];
	$vdo_length=				$result[vdo_length];
	$vdo_keyword=			$result[vdo_keyword];
	$vdo_recommend= 	$result[vdo_recommend];
	
	$L =							explode(":",$vdo_length);
	$count_L =				count($L);
	$vdo_hour =				$L[$count_L-3];
	$vdo_min  =				$L[$count_L-2];
	$vdo_sec  =				$L[$count_L-1];
	
	$_SESSION["sess_vdo_id"] =			$vdo_id;
	$_SESSION["sess_vdo_name"] =		$vdo_name;
	$_SESSION["sess_vdo_cover"] =		$vdo_cover;
	$_SESSION["sess_vdo_url"] =			base64_decode($result[vdo_url]);
	
	if($vdo_cover == ""){
		$vdo_cover_word = "NO PICTURE";
	}else{
		$vdo_cover_word = "<img src='$vdo_cover' width='200' />";
	}
	 
	$vdo_url = base64_decode($result[vdo_url]);
	$votesum = $result[vdo_votesum]; 
	$votecount = $result[vdo_votecount]; 
	
	$sub_url = explode("/",$vdo_url);
	
//	$sql_select_rating="SELECT * FROM ag_vdovote join ag_vdodetail on 
//	ag_vdovote.vdo_voteid = ag_vdodetail.vdo_voteid where ag_vdovote.vdo_voteid = $id";
//	$db_query_rating=mysql_db_query($dbname,$sql_select_rating); 
//	$result_rating = mysql_fetch_array($db_query_rating); 

	if($votesum == 0 and $votecount == 0){
		$rating=0;
	}else{
		$rating = $votesum/$votecount;
	}
?>

	document.frm_vdo_edit.txtvdoid.value =	 	("<?= $vdo_id ?>");
	document.frm_vdo_edit.txtname.value = 		("<?= $vdo_name ?>");
	document.frm_vdo_edit.txtdesc.value =  		("<?= $vdo_desc ?>");
	document.frm_vdo_edit.txtkeyword.value =  ("<?= $vdo_keyword ?>");
	document.frm_vdo_edit.txtview.value =  		("<?= $vdo_view ?>");
	document.frm_vdo_edit.txtrating.value =		("<?= $rating ?>");    //   sum/count
	document.frm_vdo_edit.txtvote.value =  		("<?= $votecount ?>");
	}

</script>

<script language="javascript">  ////ตรวจสอบ file field ว่าว่างหรือไม่ ก่อนที่จะ update แต่ยังไม่สำเร็จ
function checkblank(){
		if(document.frm_vdo_edit.txtname.value==''){
			alert('กรุณากรอกชื่อสื่อมัลติมีเดีย');
			document.frm_vdo_edit.txtname.focus();
			return false ;
		}else if(document.frm_vdo_edit.txtauthor.value==''){
			alert('กรุณากรอกชื่อหน่วยงาน/ชื่อผู้แต่ง');
			document.frm_vdo_edit.txtauthor.focus();
			return false ;		
		}else if(document.frm_vdo_edit.txthour.value=='00' && document.frm_vdo_edit.txtmin.value=='00' && document.frm_vdo_edit.txtsec.value=='00'){
			alert('กรุณากรอกความยาวสื่อมัลติมีเดีย');
			document.frm_vdo_edit.txtauthor.focus();
			return false ;		
		}else{
		
			var cb_count = 0;
			var frm_vdo_edit=document.getElementById('frm_vdo_edit');
			for(var i=0;i<frm_vdo_edit['vdotype_array[]'].length;i++){
				if (frm_vdo_edit['vdotype_array[]'][i].checked==true)
				{
					 cb_count=++cb_count;
				}
			}
			if(cb_count<=0){
			alert('กรุณาเลือกประเภทเนื้อหาอย่างน้อย 1 ประเภท');
			return false;
			}else return true;
	 			
		}
}
</script>
<script language="javascript">
function clearfield(){
	document.frm_vdo_edit.txtmainfolder.value = '';
	document.frm_vdo_edit.txtsubfolder.value =  '';
	document.frm_vdo_edit.txtname.value = 		'';
	document.frm_vdo_edit.txtdesc.value =  		'';
	document.frm_vdo_edit.txtkeyword.value =  	'';
	}
</script>
<script>
function duplicate(){
		<?
		$vdoname = $_POST[txtname];
		include "connectdb.php";
		$SQL_SELECT_DUPNAME = "SELECT count(vdo_id) FROM ag_vdodetail where vdo_name = '$vdoname' ;";
		$dupname = mysql_query($SQL_SELECT_DUPNAME);
		$dupname2 = mysql_result($dupname,0);
		?>
		var dupname2 = <?=$dupname2?>
		return (dupname2)
}
</script>
<script language="javascript">
function reset_view(){
    window.location="reset_vdo_stat.php?id=<?=$vdo_id?>&amp;reset_code=view";
}
function reset_stat(){
    window.location="reset_vdo_stat.php?id=<?=$vdo_id?>&amp;reset_code=vote";
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ยินดีต้อนรับเข้าสู่ ระบบบริการสื่อมัลติมีเดียด้านการเกษตร</title>
<link rel="stylesheet" href="standard.css" type="text/css" />

<script type="text/javascript">
<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
<style type="text/css">      
 /* css code สำหรับรูปแบบของภาพ ที่ต้องการแสดง */    
 div.bigGallPic{     
     position:fixed;     
     margin:auto;     
     top:150px;     
     left:150px;     
     padding:3px;     
     text-align:center;     
     background-color:#FFFFFF;     
     border:5px solid #666666;     
     display:none;     
     cursor:pointer;     
 }     
</style>
<script type="text/javascript">    
function setPic(imgShow){   
    var showBig=document.getElementById('bigGallDiv');   
    showBig.style.display='block';   		
	showBig.style.visibility='hidden';   
    showBig.innerHTML="<img src='"+imgShow+"' title='คลิกที่รูปเืพื่อปิด' >";   
	setTimeout("showPic()",500);
} 
function  showPic(){
	var showBig=document.getElementById('bigGallDiv');   
    var LeftVal=0;   	
    if(showBig.innerHTML!=""){   
		LeftVal=showBig.offsetWidth;      					
		LeftVal=(gWH().width-LeftVal)/2;   	
    }   
	showBig.style.left=LeftVal+"px";   
	showBig.style.visibility='visible';   	
}
function gWH(){ // ฟังก์ชันหาความกว้างและความสูงของหน้าเพจ   
    var e = window, a = 'inner';   
    if ( !( 'innerWidth' in window ) ){   
        a = 'client';   
        e = document.documentElement || document.body;   
    }   
    return { width : e[ a+'Width' ] , height : e[ a+'Height' ] }   
}  
</script>  

</head>

<body onLoad="MM_preloadImages('img/m_main2.jpg','img/m_register2.jpg','img/m_multimedia2.jpg','img/m_manual2.jpg','img/m_evaluate2.jpg','img/m_admin2.jpg','img/m_static2.jpg','img/m_topten2.jpg')">
<table width="1024" height="659" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#666600">
  <tr>
    <td height="215" align="center" valign="top" bgcolor="#CCCCCC"><table width="1024" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="170" background="img/headNew2.jpg" bgcolor="#FFFFFF">&nbsp;</td>
      </tr>
    </table>
        <table width="824" border="0" cellpadding="0" cellspacing="0" bordercolor="#FF0000">
          <tr>
            <td width="103" height="45" align="center"><a href="index.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image12','','img/m_main2.jpg',1)"><img src="img/m_main.jpg" name="Image12" width="115" height="45" border="0" id="Image12" /></a></td>
            <td width="103" align="right"><a href="user_register.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image13','','img/m_register2.jpg',1)"><img src="img/m_register.jpg" name="Image13" width="115" height="45" border="0" id="Image13" /></a></td>
            <td width="103" align="right"><a href="vdo_list.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image14','','img/m_multimedia2.jpg',1)"><img 
src="img/m_multimedia.jpg" name="Image14" width="117" height="45" border="0" id="Image14" /></a></td>
            <td width="103"><a href="vdo_top10.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image11','','img/m_topten2.jpg',1)"><img 
src="img/m_topten.jpg" name="Image11" width="115" height="45" border="0" id="Image11" /></a></td>
            <td width="103"><a href="admin_report_search.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image10','','img/m_static2.jpg',1)"><img 
src="img/m_static.jpg" name="Image10" width="215" height="45" border="0" id="Image10" /></a></td>
            <td width="103"><a href="manual.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image9','','img/m_manual2.jpg',1)"><img src="img/m_manual.jpg" name="Image9" width="117" height="45" border="0" id="Image9" /></a></td>
            <td width="103"><a href="evaluate_overview.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image8','','img/m_evaluate2.jpg',1)"><img src="img/m_evaluate.jpg" name="Image8" width="115" height="45" border="0" id="Image8" /></a></td>
            <td width="103"><a href="admin_login.php" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image15','','img/m_admin2.jpg',1)"><img src="img/m_admin.jpg" name="Image15" width="115" height="45" border="0" id="Image15" /></a></td>
          </tr>
        </table></td>
  </tr>
  <tr>
    <td width="1024" height="66" align="center" valign="top" bgcolor="#FFFFFF"><table width="1024" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="25" height="25" background="img/tb/tb_left_top.jpg">&nbsp;</td>
        <td height="25" background="img/tb/tb_top.jpg">&nbsp;</td>
        <td width="25" height="25" background="img/tb/tb_right_top.jpg">&nbsp;</td>
      </tr>
      <tr>
        <td width="25" align="left" background="img/tb/tb_left.jpg">&nbsp;</td>
        <td align="center"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="30" align="left" bgcolor="#CCFF00" class="style7"><span class="scapmain style7">&nbsp;<img src="img/img05.gif" align="absbottom" /></span> แก้ไขรายการสื่อมัลติมีเดีย</td>
          </tr>
          <tr>
            <td align="center" bgcolor="#FFFFFF"><p>&nbsp;</p>
                   <?php if($vdo_cover == ""){$vdo_cover = "pic/no_image.gif";}?>
                  <table width="60%" border="1" cellpadding="0" cellspacing="0" bordercolor="#999999">
<form action="vdo_edit2.php" method="post" name="frm_vdo_edit"  id="frm_vdo_edit" onSubmit="return checkblank();" >

                        <tr>
                          <td align="center" nowrap="nowrap" bordercolor="#CCCCCC" bgcolor="#FFCC00" class="style28">
                         <p> <input type="checkbox" name="cb_recommend" id="cb_recommend"   <? if($vdo_recommend == "1") echo "checked";?>/>
                          แนะนำ</p></td>
                          <td colspan="2" rowspan="2" bgcolor="#FFF2A8">
                          
						 
 <div class="bigGallPic" id="bigGallDiv" onClick="this.style.display='none'"></div>  

<a href="javascript:setPic('<?=$vdo_cover?>');"><img src="<?=$vdo_cover?>" border="0" width="250"  hspace='5' vspace='5' /></a><br></td>
                        </tr>
                        <tr>
                          <td align="center" nowrap="nowrap" bordercolor="#CCCCCC" bgcolor="#FFCC00" class="style28">รูปหน้าปก</td>
                      </tr>
                        <tr>
                          <td height="30" align="center" nowrap="nowrap" bordercolor="#CCCCCC" bgcolor="#FFCC00" class="style28">ที่อยู่ไฟล์หน้าปก(เดิม)</td>
                          <td colspan="2" bgcolor="#FFF2A8"><?php echo $vdo_cover; ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
                          <a href="vdo_uploadcover.php" target="_self" class="style28"><strong>แก้ไขรูปภาพ</strong></a>                          </td>
                        </tr>
                        <tr>
                          <td width="150" height="30" align="center" nowrap="nowrap" bordercolor="#CCCCCC" bgcolor="#FFCC00" class="style28">ที่อยู่ไฟล์(เดิม)</td>
                          <td colspan="2" bgcolor="#FFF2A8"><?php echo $vdo_url; ?>&nbsp;</td>
                        </tr>
                        <tr>
                          <td width="150" height="30" align="center" nowrap="nowrap" bordercolor="#CCCCCC" bgcolor="#FFCC00" class="style28">ที่อยู่ไฟล์</td>
                          <td colspan="2" bgcolor="#FFF2A8">
                            <input name="txtfile" type="text" id="txtfile" value="<?php echo $vdo_url; ?>" size="45" />
                            <input type="hidden" name="filefield" id="filefield" value="<?=$_POST["txtfile"]?>" />                          </td>
                        </tr>
                        <tr>
                          <td width="150" height="30" align="center" nowrap="nowrap" bordercolor="#CCCCCC" bgcolor="#FFCC00" class="style28">หมายเลข</td>
                          <td colspan="2" bgcolor="#FFF2A8">
                 <input name="txtvdoid" type="text" disabled="disabled" class="style28" id="txtvdoid" value="<?php echo $vdo_id; ?>" size="20" cols="20" /></td>
                        </tr>
                        <tr>
                          <td height="30" align="center" nowrap="nowrap" bordercolor="#CCCCCC" bgcolor="#FFCC00" class="style28">ชื่อชุด</td>
                          <td colspan="2" bgcolor="#FFF2A8"><input name="txtsrname" type="text" id="txtsrname" value="<?php echo $vdo_series_name; ?>" size="40" /></td>
                        </tr>
                        <tr>
                          <td width="150" height="30" align="center" nowrap="nowrap" bordercolor="#CCCCCC" bgcolor="#FFCC00" class="style28">ชื่อเรื่อง</td>
                          <td colspan="2" bgcolor="#FFF2A8"><input name="txtname" type="text" class="style28" id="txtname" value="<?php echo $vdo_name; ?>" size="50" /> 
                          <span class="style29">*</span></td>
                        </tr>
                        <tr>
                          <td width="150" height="30" align="center" nowrap="nowrap" bordercolor="#CCCCCC" bgcolor="#FFCC00" class="style28">คำบรรยายเพิ่มเติม</span></td>
                          <td colspan="2">
                            <textarea name="txtdesc" id="txtdesc" cols="55" rows="5"><?php echo $vdo_desc; ?></textarea>                          </td>
                        </tr>
                        <tr>
                          <td height="30" align="center" nowrap="nowrap" bordercolor="#CCCCCC" bgcolor="#FFCC00" class="style28">หน่วยงาน / ชื่อผู้แต่ง</td>
                          <td colspan="2" bgcolor="#FFF2A8"><input name="txtauthor" type="text" id="txtauthor" value="<?php echo $vdo_author; ?>" size="40" />
                            <span class="style29">*</span></td>
                        </tr>
                        <tr>
                          <td height="30" align="center" nowrap="nowrap" bordercolor="#CCCCCC" bgcolor="#FFCC00" class="style28"><span class="style28">ปีที่จัดทำ</span></td>
                          <td colspan="2" bgcolor="#FFF2A8"><input name="txtyear" type="text" id="txtyear" value="<?php echo $vdo_year; ?>" size="4" maxlength="4" /></td>
                        </tr>
                        <tr>
                          <td height="30" align="center" nowrap="nowrap" bordercolor="#CCCCCC" bgcolor="#FFCC00" class="style28"><span class="style28">ความยาว</span></td>
                          <td colspan="2" bgcolor="#FFF2A8" class="style28">&nbsp;
                          <?php echo " [ ".$vdo_length." ]  "; ?>&nbsp;
                            <select name="txthour" id="txthour">
                              <option value="00"  <? if($vdo_hour == '00') echo"selected" ?> >00</option>
                              <option value="01"  <? if($vdo_hour == '01') echo"selected" ?> >01</option>
                              <option value="02"  <? if($vdo_hour == '02') echo"selected" ?> >02</option>
                              <option value="03"  <? if($vdo_hour == '03') echo"selected" ?> >03</option>
                              <option value="04"  <? if($vdo_hour == '04') echo"selected" ?> >04</option>
                              <option value="05"  <? if($vdo_hour == '05') echo"selected" ?> >05</option>
                              <option value="06"  <? if($vdo_hour == '06') echo"selected" ?> >06</option>
                              <option value="07"  <? if($vdo_hour == '07') echo"selected" ?> >07</option>
                              <option value="08"  <? if($vdo_hour == '08') echo"selected" ?> >08</option>
                              <option value="09"  <? if($vdo_hour == '09') echo"selected" ?> >09</option>
                              <option value="10"  <? if($vdo_hour == '10') echo"selected" ?> >10</option>
                              </select>
                          ชม :
                          <select name="txtmin" id="txtmin">
                            <option value="00" <? if($vdo_min == '00') echo"selected" ?> >00</option>
                            <option value="01" <? if($vdo_min == '01') echo"selected" ?> >01</option>
                            <option value="02" <? if($vdo_min == '02') echo"selected" ?> >02</option>
                            <option value="03" <? if($vdo_min == '03') echo"selected" ?> >03</option>
                            <option value="04" <? if($vdo_min == '04') echo"selected" ?> >04</option>
                            <option value="05" <? if($vdo_min == '05') echo"selected" ?> >05</option>
                            <option value="06" <? if($vdo_min == '06') echo"selected" ?> >06</option>
                            <option value="07" <? if($vdo_min == '07') echo"selected" ?> >07</option>
                            <option value="08" <? if($vdo_min == '08') echo"selected" ?> >08</option>
                            <option value="09" <? if($vdo_min == '09') echo"selected" ?> >09</option>
                            <option value="10" <? if($vdo_min == '10') echo"selected" ?> >10</option>
                            <option value="11" <? if($vdo_min == '11') echo"selected" ?> >11</option>
                            <option value="12" <? if($vdo_min == '12') echo"selected" ?> >12</option>
                            <option value="13" <? if($vdo_min == '13') echo"selected" ?> >13</option>
                            <option value="14" <? if($vdo_min == '14') echo"selected" ?> >14</option>
                            <option value="15" <? if($vdo_min == '15') echo"selected" ?> >15</option>
                            <option value="16" <? if($vdo_min == '16') echo"selected" ?> >16</option>
                            <option value="17" <? if($vdo_min == '17') echo"selected" ?> >17</option>
                            <option value="18" <? if($vdo_min == '18') echo"selected" ?> >18</option>
                            <option value="19" <? if($vdo_min == '19') echo"selected" ?> >19</option>
                            <option value="20" <? if($vdo_min == '20') echo"selected" ?> >20</option>
                            <option value="21" <? if($vdo_min == '21') echo"selected" ?> >21</option>
                            <option value="22" <? if($vdo_min == '22') echo"selected" ?> >22</option>
                            <option value="23" <? if($vdo_min == '23') echo"selected" ?> >23</option>
                            <option value="24" <? if($vdo_min == '24') echo"selected" ?> >24</option>
                            <option value="25" <? if($vdo_min == '25') echo"selected" ?> >25</option>
                            <option value="26" <? if($vdo_min == '26') echo"selected" ?> >26</option>
                            <option value="27" <? if($vdo_min == '27') echo"selected" ?> >27</option>
                            <option value="28" <? if($vdo_min == '28') echo"selected" ?> >28</option>
                            <option value="29" <? if($vdo_min == '29') echo"selected" ?> >29</option>
                            <option value="30" <? if($vdo_min == '30') echo"selected" ?> >30</option>
                            <option value="31" <? if($vdo_min == '31') echo"selected" ?> >31</option>
                            <option value="32" <? if($vdo_min == '32') echo"selected" ?> >32</option>
                            <option value="33" <? if($vdo_min == '33') echo"selected" ?> >33</option>
                            <option value="34" <? if($vdo_min == '34') echo"selected" ?> >34</option>
                            <option value="35" <? if($vdo_min == '35') echo"selected" ?> >35</option>
                            <option value="36" <? if($vdo_min == '36') echo"selected" ?> >36</option>
                            <option value="37" <? if($vdo_min == '37') echo"selected" ?> >37</option>
                            <option value="38" <? if($vdo_min == '38') echo"selected" ?> >38</option>
                            <option value="39" <? if($vdo_min == '39') echo"selected" ?> >39</option>
                            <option value="40" <? if($vdo_min == '40') echo"selected" ?> >40</option>
                            <option value="41" <? if($vdo_min == '41') echo"selected" ?> >41</option>
                            <option value="42" <? if($vdo_min == '42') echo"selected" ?> >42</option>
                            <option value="43" <? if($vdo_min == '43') echo"selected" ?> >43</option>
                            <option value="44" <? if($vdo_min == '44') echo"selected" ?> >44</option>
                            <option value="45" <? if($vdo_min == '45') echo"selected" ?> >45</option>
                            <option value="46" <? if($vdo_min == '46') echo"selected" ?> >46</option>
                            <option value="47" <? if($vdo_min == '47') echo"selected" ?> >47</option>
                            <option value="48" <? if($vdo_min == '48') echo"selected" ?> >48</option>
                            <option value="49" <? if($vdo_min == '49') echo"selected" ?> >49</option>
                            <option value="50" <? if($vdo_min == '50') echo"selected" ?> >50</option>
                            <option value="51" <? if($vdo_min == '51') echo"selected" ?> >51</option>
                            <option value="52" <? if($vdo_min == '52') echo"selected" ?> >52</option>
                            <option value="53" <? if($vdo_min == '53') echo"selected" ?> >53</option>
                            <option value="54" <? if($vdo_min == '54') echo"selected" ?> >54</option>
                            <option value="55" <? if($vdo_min == '55') echo"selected" ?> >55</option>
                            <option value="56" <? if($vdo_min == '56') echo"selected" ?> >56</option>
                            <option value="57" <? if($vdo_min == '57') echo"selected" ?> >57</option>
                            <option value="58" <? if($vdo_min == '58') echo"selected" ?> >58</option>
                            <option value="59" <? if($vdo_min == '59') echo"selected" ?> >59</option>
                          </select>
                          นาที 
                         :
                          <select name="txtsec" id="txtsec">
                           	<option value="00" <? if($vdo_sec == '00') echo"selected" ?> >00</option>
                            <option value="01" <? if($vdo_sec == '01') echo"selected" ?> >01</option>
                            <option value="02" <? if($vdo_sec == '02') echo"selected" ?> >02</option>
                            <option value="03" <? if($vdo_sec == '03') echo"selected" ?> >03</option>
                            <option value="04" <? if($vdo_sec == '04') echo"selected" ?> >04</option>
                            <option value="05" <? if($vdo_sec == '05') echo"selected" ?> >05</option>
                            <option value="06" <? if($vdo_sec == '06') echo"selected" ?> >06</option>
                            <option value="07" <? if($vdo_sec == '07') echo"selected" ?> >07</option>
                            <option value="08" <? if($vdo_sec == '08') echo"selected" ?> >08</option>
                            <option value="09" <? if($vdo_sec == '09') echo"selected" ?> >09</option>
                            <option value="10" <? if($vdo_sec == '10') echo"selected" ?> >10</option>
                            <option value="11" <? if($vdo_sec == '11') echo"selected" ?> >11</option>
                            <option value="12" <? if($vdo_sec == '12') echo"selected" ?> >12</option>
                            <option value="13" <? if($vdo_sec == '13') echo"selected" ?> >13</option>
                            <option value="14" <? if($vdo_sec == '14') echo"selected" ?> >14</option>
                            <option value="15" <? if($vdo_sec == '15') echo"selected" ?> >15</option>
                            <option value="16" <? if($vdo_sec == '16') echo"selected" ?> >16</option>
                            <option value="17" <? if($vdo_sec == '17') echo"selected" ?> >17</option>
                            <option value="18" <? if($vdo_sec == '18') echo"selected" ?> >18</option>
                            <option value="19" <? if($vdo_sec == '19') echo"selected" ?> >19</option>
                            <option value="20" <? if($vdo_sec == '20') echo"selected" ?> >20</option>
                            <option value="21" <? if($vdo_sec == '21') echo"selected" ?> >21</option>
                            <option value="22" <? if($vdo_sec == '22') echo"selected" ?> >22</option>
                            <option value="23" <? if($vdo_sec == '23') echo"selected" ?> >23</option>
                            <option value="24" <? if($vdo_sec == '24') echo"selected" ?> >24</option>
                            <option value="25" <? if($vdo_sec == '25') echo"selected" ?> >25</option>
                            <option value="26" <? if($vdo_sec == '26') echo"selected" ?> >26</option>
                            <option value="27" <? if($vdo_sec == '27') echo"selected" ?> >27</option>
                            <option value="28" <? if($vdo_sec == '28') echo"selected" ?> >28</option>
                            <option value="29" <? if($vdo_sec == '29') echo"selected" ?> >29</option>
                            <option value="30" <? if($vdo_sec == '30') echo"selected" ?> >30</option>
                            <option value="31" <? if($vdo_sec == '31') echo"selected" ?> >31</option>
                            <option value="32" <? if($vdo_sec == '32') echo"selected" ?> >32</option>
                            <option value="33" <? if($vdo_sec == '33') echo"selected" ?> >33</option>
                            <option value="34" <? if($vdo_sec == '34') echo"selected" ?> >34</option>
                            <option value="35" <? if($vdo_sec == '35') echo"selected" ?> >35</option>
                            <option value="36" <? if($vdo_sec == '36') echo"selected" ?> >36</option>
                            <option value="37" <? if($vdo_sec == '37') echo"selected" ?> >37</option>
                            <option value="38" <? if($vdo_sec == '38') echo"selected" ?> >38</option>
                            <option value="39" <? if($vdo_sec == '39') echo"selected" ?> >39</option>
                            <option value="40" <? if($vdo_sec == '40') echo"selected" ?> >40</option>
                            <option value="41" <? if($vdo_sec == '41') echo"selected" ?> >41</option>
                            <option value="42" <? if($vdo_sec == '42') echo"selected" ?> >42</option>
                            <option value="43" <? if($vdo_sec == '43') echo"selected" ?> >43</option>
                            <option value="44" <? if($vdo_sec == '44') echo"selected" ?> >44</option>
                            <option value="45" <? if($vdo_sec == '45') echo"selected" ?> >45</option>
                            <option value="46" <? if($vdo_sec == '46') echo"selected" ?> >46</option>
                            <option value="47" <? if($vdo_sec == '47') echo"selected" ?> >47</option>
                            <option value="48" <? if($vdo_sec == '48') echo"selected" ?> >48</option>
                            <option value="49" <? if($vdo_sec == '49') echo"selected" ?> >49</option>
                            <option value="50" <? if($vdo_sec == '50') echo"selected" ?> >50</option>
                            <option value="51" <? if($vdo_sec == '51') echo"selected" ?> >51</option>
                            <option value="52" <? if($vdo_sec == '52') echo"selected" ?> >52</option>
                            <option value="53" <? if($vdo_sec == '53') echo"selected" ?> >53</option>
                            <option value="54" <? if($vdo_sec == '54') echo"selected" ?> >54</option>
                            <option value="55" <? if($vdo_sec == '55') echo"selected" ?> >55</option>
                            <option value="56" <? if($vdo_sec == '56') echo"selected" ?> >56</option>
                            <option value="57" <? if($vdo_sec == '57') echo"selected" ?> >57</option>
                            <option value="58" <? if($vdo_sec == '58') echo"selected" ?> >58</option>
                            <option value="59" <? if($vdo_sec == '59') echo"selected" ?> >59</option>
                          </select>
วินาที 
                          <span class="style29">*</span></td>
                        </tr>
                        <tr>
                          <td width="150" height="30" align="center" nowrap="nowrap" bordercolor="#CCCCCC" bgcolor="#FFCC00" class="style28">คำสำคัญ</td>
                          <td colspan="2" bgcolor="#FFF2A8">
                            <p>
                              <textarea name="txtkeyword" id="txtkeyword" cols="55" rows="3"><?php echo $vdo_keyword; ?></textarea>
                              
                              <span class="style29">*</span> <span class="style28">ตัวอย่าง keyword1,keyword2</span> </p></td>
                        </tr>
                        <tr>
                          <td width="150" height="30" align="center" nowrap="nowrap" bordercolor="#CCCCCC" bgcolor="#FFCC00" class="style28">ประเภทเนื้อหา</td>
                          <td nowrap="nowrap" bgcolor="#FFF2A8" class="style28">
                            <?php 

        $SQL_SELECT_VDOTYPE = "SELECT * FROM ag_vdotype ORDER BY vdo_typeid desc";
        $result = mysql_query($SQL_SELECT_VDOTYPE);
        while ( $rs = mysql_fetch_array( $result ) ) //นำค่าี่ที่ผ่านการคิวรี่จากตัวแปร $result มาทำการวนลูปเพื่อเอาค่าในแต่ละฟิลด์ออกมาโชว์แสดงผล
	{ 
			$vdo_typeid = $rs[vdo_typeid];									
			$vdo_type = $rs[vdo_type];	
			
			$SQL_SELECT_VDOTYPEDETAIL = "SELECT * FROM ag_vdotypedetail WHERE vdo_id=$id and vdo_typeid=$vdo_typeid ";	
			$result_typedetail = mysql_query($SQL_SELECT_VDOTYPEDETAIL);											
			$num_rows=mysql_num_rows($result_typedetail);
			
			 ?>
                            <input type='checkbox' name='vdotype_array[]' value="<?=$vdo_typeid?>"  <? if($num_rows == 1) echo "checked";?> />
                            &nbsp;<font color='#372412'>
                              <?=$vdo_type?>
                              </font><br />
                            <?
			}
        	?>                          </td>
                          <td bgcolor="#FFF2A8" class="style28"><span class="style29">*</span> <span class="style28">กรุณาเลือกอย่างน้อย 1 ประเภท</span></td>
                        </tr>
                        <tr>
                          <td width="150" height="30" align="center" nowrap="nowrap" bordercolor="#CCCCCC" bgcolor="#FFCC00" class="style28">ประเภทไฟล์สื่อมัลติมีเดีย</td>
                          <td colspan="2" bgcolor="#FFF2A8" class="style28">
                            <?php 
        $SQL_SELECT_MEDIATYPE = "SELECT * FROM ag_mediatype ORDER BY media_typeid";
        $result = mysql_query($SQL_SELECT_MEDIATYPE);
        while ( $rs = mysql_fetch_array( $result ) ) //นำค่าี่ที่ผ่านการคิวรี่จากตัวแปร $result มาทำการวนลูปเพื่อเอาค่าในแต่ละฟิลด์ออกมาโชว์แสดงผล
			{ 
			$media_typeid = $rs[media_typeid];									
			$media_type = $rs[media_type];	
			
			$SQL_SELECT_VDODETAIL = "SELECT * FROM ag_vdodetail WHERE vdo_id=$id and media_typeid=$media_typeid ";	
			$result_mediatype = mysql_query($SQL_SELECT_VDODETAIL);											
			$num_rows=mysql_num_rows($result_mediatype);
			
															
			?>
                            <input type='radio' name='mediatype_array[]' value="<?=$media_typeid?>"  <? if($num_rows == 1) echo "checked";?> />
                            &nbsp;<font color='#372412'>
                              <?=$media_type?>
                              </font><br />
                            <?		 
			}
        	?>                          </td>
                        </tr>
                        <tr>
                          <td width="150" height="30" align="center" nowrap="nowrap" bordercolor="#CCCCCC" bgcolor="#FFCC00" class="style28">ผู้ชม</td>
                          <td width="120" align="left" nowrap="nowrap" bgcolor="#FFF2A8"><input name="txtview" type="text" disabled="disabled" class="style28" id="txtview" value="<?php echo $vdo_view; ?>" size="20" cols="20" /></td>
                          <td width="213" align="left" nowrap="nowrap" bgcolor="#FFF2A8"><span class="style28">
                          <input type="button" name="btn_reset1" id="btn_reset1" value="เริ่มนับจำนวนผู้ชมใหม่" onClick="reset_view()" />
                          </span></td>
                        </tr>
                        <tr>
                          <td width="150" height="30" align="center" nowrap="nowrap" bordercolor="#CCCCCC" bgcolor="#FFCC00" class="style28">เรทติ้ง</td>
                          <td align="left" nowrap="nowrap" bgcolor="#FFF2A8"><input name="txtrating" type="text" disabled="disabled" class="style28" id="txtrating" value="<?php echo $rating; ?>" size="20" cols="20" /></td>
                          <td rowspan="2" align="left" nowrap="nowrap" bgcolor="#FFF2A8"><span class="style28">
                            <input type="button" name="btn_reset2" id="btn_reset2" value="เริ่มจับสถิติใหม่" onClick="reset_stat()" />
                          </span></td>
                        </tr>
                        <tr>
                          <td width="150" height="30" align="center" nowrap="nowrap" bordercolor="#CCCCCC" bgcolor="#FFCC00" class="style28">โหวต</td>
                          <td align="left" nowrap="nowrap" bgcolor="#FFF2A8"><input name="txtvote" type="text" disabled="disabled" class="style28" id="txtvote" value="<?php echo $votecount; ?>" size="20" cols="20" /></td>
                        </tr>
                        <tr>
                          <td colspan="3" align="center" nowrap="nowrap"><span class="style18 style18">
                            <input type="hidden" name="id" id="id" value="<?=$vdo_id?>" />
                            <input type="hidden" name="oldname" id="oldname" value="<?=$vdo_name?>" />
                            <input type="hidden" name="txtview" id="txtview" value="<?=$vdo_view?>" />
                            <input type="hidden" name="txtvotesum" id="txtvotesum" value="<?=$votesum?>" />
                            <input type="hidden" name="txtvotecount" id="txtvotecount" value="<?=$votecount?>" />
                            <input type="hidden" name="fileold" id="fileold" value="<?=$vdo_url?>" />
                            <input type="submit" name="button" id="button" value="ยืนยัน" />
                            <a name="top" id="space"></a>
                           <!-- <input type="reset" name="button2" id="button2" value="ล้าง" onclick="clearfield();" />-->
                            &nbsp;</span></td>
                        </tr>
                      </form>
                    </table>
                  <p>&nbsp;</p>
              </td>
          </tr>
          <tr>
            <td height="25" bgcolor="#CCFF00">&nbsp;</td>
          </tr>
        </table></td>
        <td width="25" align="right" background="img/tb/tb_right.jpg">&nbsp;</td>
      </tr>
      <tr>
        <td width="25" height="25" background="img/tb/tb_left_foot.jpg">&nbsp;</td>
        <td height="25" background="img/tb/tb_foot.jpg">&nbsp;</td>
        <td width="25" height="25" background="img/tb/tb_right_foot.jpg">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td width="1024" align="center" valign="bottom"><table width="50%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="25">&nbsp;</td>
      </tr>
    </table>
        <table width="1024" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="50"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="25" height="25" background="img/tb/tb_left_top.jpg">&nbsp;</td>
                  <td background="img/tb/tb_top.jpg">&nbsp;</td>
                  <td width="25" height="25" background="img/tb/tb_right_top.jpg">&nbsp;</td>
                </tr>
                <tr>
                  <td width="25" align="left" background="img/tb/tb_left.jpg">&nbsp;</td>
                  <td height="25" align="center" valign="middle" bgcolor="#CCFF00"><table width="96%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td height="25" align="center"><strong>ศูนย์ความรู้ด้านการเกษตร สำนักหอสมุด มหาวิทยาลัยเกษตรศาสตร์</strong></td>
                      </tr>
                  </table></td>
                  <td width="25" align="right" background="img/tb/tb_right.jpg">&nbsp;</td>
                </tr>
                <tr>
                  <td width="25" height="25" background="img/tb/tb_left_foot.jpg">&nbsp;</td>
                  <td background="img/tb/tb_foot.jpg">&nbsp;</td>
                  <td width="25" height="25" background="img/tb/tb_right_foot.jpg">&nbsp;</td>
                </tr>
            </table></td>
          </tr>
      </table></td>
  </tr>
</table>
<p>&nbsp;</p>
</body>
</html>
<script>
getdetail();
</script>